package com.fgxia.admin.controller.web;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.fgxia.admin.service.IAdminWaybillService;
import com.ruoyi.business.domain.bo.admin.AdminFreightQueryBo;
import com.ruoyi.business.domain.vo.admin.AdminFreightInfoVo;
import com.ruoyi.business.domain.vo.admin.AdminWaybillQueryVo;
import com.ruoyi.business.domain.vo.admin.AdminWaybillRevaluationVo;
import com.ruoyi.business.domain.vo.admin.AdminWaybillVehicleTrailVo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * web端运单管理
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/web/waybill")
public class WebWaybillController extends BaseController {

    private final IAdminWaybillService waybillService;

    /**
     * 获取运单列表
     */
    @SaCheckPermission("waybill:waybill:list")
    @GetMapping("/list")
    public TableDataInfo<AdminFreightInfoVo> listWaybill(AdminFreightQueryBo freightQueryBo, PageQuery pageQuery) {
        return waybillService.listWaybill(freightQueryBo, pageQuery);
    }

    /**
     * 获取运单详情
     */
    @SaCheckPermission("waybill:waybill:query")
    @GetMapping("/{waybillId}")
    public R<AdminWaybillQueryVo> getWaybill(@PathVariable Long waybillId) {
        return R.ok(waybillService.queryWaybillById(waybillId));
    }

    /**
     * 获取改价记录列表
     */
    @SaCheckPermission("waybill:price:list")
    @GetMapping("/price/{waybillId}")
    public R<AdminWaybillRevaluationVo> listWaybillPrice(@PathVariable Long waybillId) {
        return R.ok(waybillService.listWaybillPrice(waybillId));
    }

    /**
     * 运单定位记录列表
     */
    @SaCheckPermission("waybill:location:list")
    @GetMapping("/location/{waybillId}")
    public R<AdminWaybillVehicleTrailVo> listWaybillLocation(@PathVariable Long waybillId) {
        return R.ok(waybillService.listWaybillVehicleTrail(waybillId));
    }

}
